package com.ly.user.web;

import javax.servlet.http.HttpServletRequest;
import com.yc.login.bean.LoginProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Enumeration;


@RestController
@RefreshScope
public class UserDo {

    @RequestMapping("user")
    String user(HttpServletRequest request) {
        Enumeration<String> headerNames = request.getHeaderNames();
        while (headerNames.hasMoreElements()) {
            String headerName = headerNames.nextElement();
            String headerValue = request.getHeader(headerName);
            System.out.println(headerName + ":" + headerValue);
        }
        return "user" + request.getServerPort();
    }

    @Autowired
    LoginProperties loginProperties;

    @Value("${login.usernameColumn}")
    String usernameColumn;

    @RequestMapping("userProps")
    LoginProperties getLoginProperties() {
        return loginProperties;
    }
}
